<?php
namespace App\Http\Controllers\Api\Jbp;

use App\Http\Controllers\Controller;
use App\Jobs\GameJbpSeize;
use App\Jobs\SendWechatMessage;
use App\User;
use App\UserCoinLog;
use App\GameZghpt;
use App\Jobs\JoinTeam;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;

/**
 * 聚宝盆
 *
 * @version 1.0.0
 */
class JbpController extends Controller {

    //聚宝盆
    const business_id  = 9;
    //活动时长，单位：秒
    const activity_time = 600;
    //发放元宝总数量
    const yb_total_num = 10000;

    //元宝类型
    const yb_type = [
        'Y' => ['rate' => 40, 'limit' => 3, 'xyb' => 0.35],//银元宝
        'J' => ['rate' => 10, 'limit' => 5, 'xyb' => 0.25],//金元宝
        'L' => ['rate' => 25, 'limit' => 20, 'xyb' => 0.07],//蓝元宝
        'H' => ['rate' => 25, 'limit' => 100, 'xyb' => 0.02],//红元宝
    ];

    //开放时间
    const times = [
        1491094800 => '224,444,668,866,1036,1188,1382,1575,1794,2025,2258,2453,2652,2880,3049,3232,3468,3634,3871,4067,4242,4434,4600,4803,5048,5278,5457,5680,5858,6108,6327,6526,6690,6937,7120,7305,7457,7653,7861,8066,8239,8450,8680,8884,9110,9314,9547,9792,10006,10200,10417,10616,10772,10946,11112,11265,11468,11699,11863,12038,12280,12526,12753,13000,13183,13384,13594,13752,13915,14160,14366,14583,14814,14970,15129,15346,15589,15758,15967,16123,16338,16557,16759,16964,17118,17344,17553,17705,17944,18137,18327,18568,18723,18964,19182,19423,19612,19802,19984,20207,20360,20598,20835,21024,21244,21424,21640,21829,22064,22222,22437,22629,22824,22982,23169,23365,23596,23753,23987,24160,24405,24567,24718,24914,25111,25348,25593,25805,25976,26216,26431,26635,26850,27037,27254,27468,27646,27837,28001,28202,28390,28547,28716,28883,29116,29305,29534,29749,29914,30075,30235,30465,30657,30857,31085,31276,31506,31741,31966,32200,32450,32686,32847,33000,33162,33389,33570,33766,33989,34142,34320,34477,34669,34870,35066,35236,35475,35678,35878,36028,36194,36368,36563,36726,36927,37138,37375,37538,37769,37986,38174,38411,38643,38836,39071,39275,39516,39701,39864,40033,40197,40378,40626,40846,41070,41283,41525,41690,41922,42076,42306,42458,42705,42859,43100,43255,43437,43663,43888,44091,44264,44415,44638,44798,44991,45190,45403,45626,45795,45978,46213,46454,46609,46794,47006,47235,47404,47591,47809,48003,48176,48411,48577,48812,48976,49134,49328,49548,49726,49884,50104,50292,50457,50687,50918,51123,51342,51552,51756,51917,52144,52361,52564,52723,52885,53054,53248,53440,53645,53841,54047,54274,54484,54691,54900,55150,55332,55540,55766,55997,56228,56459,56657,56814,57036,57278,57479,57648,57896,58090,58259,58488,58653,58870,59024,59243,59468,59652,59809,60019,60215,60454,60628,60833,60989,61166,61341,61529,61760,62000,62227,62473,62647,62822,62999,63225,63400,63555,63799,64028,64231,64428,64659,64811,64987,65160,65339,65522,65756,65958,66169,66411,66562,66735,66932,67085,67289,67453,67699,67863,68072,68225,68423,68591,68827,69052,69216,69388,69563,69731,69927,70153,70337,70567,70746,70994,71178,71388,71591,71819,72056,72280,72477,72649,72869,73077,73322,73569,73724,73883,74089,74292,74513,74750,74965,75154,75337,75489,75661,75900,76073,76258,76446,76611,76792,77030,77198,77406,77593,77764,77946,78164,78367,78571,78791,79020,79176,79382,79593,79750,79957,80173,80397,80555,80803,80997,81162,81395,81552,81752,81951,82124,82291,82483,82704,82901,83052,83285,83487,83726,83877,84095,84307,84502,84710,84959,85159,85359,85540,85752,85993,86176,86414,86567,86784,87014,87260,87431,87599,87765,87970,88162,88365,88545,88749,88965,89147,89327,89524,89732,89976,90162,90396,90634,90866,91054,91273,91459,91657,91903,92096,92260,92426,92634,92844,93019,93225,93378,93627,93793,93945,94160,94326,94564,94791,95021,95218,95417,95648,95887,96100,96276,96512,96743,96907,97101,97263,97422,97622,97789,98019,98187,98341,98558,98732,98920,99115,99349,99526,99759,99940,100130,100288,100534,100756,100964,101146,101389,101545,101733,101929,102166,102415,102573,102807,102976,103137,103337,103497,103677,103857,104097,104344,104566,104766,104992,105240,105434,105678,105925,106138,106371,106554,106713,106897,107085,107256,107455,107608,107764,107918,108102,108311,108464,108649,108888,109046,109276,109475,109661,109818,110045,110290,110509,110702,110879,111061,111243,111421,111663,111813,112012,112182,112407,112651,112808,112960,113158,113358,113519,113769,113938,114180,114358,114523,114719,114909,115147,115333,115496,115702,115879,116064,116310,116507,116700,116866,117102,117282,117519,117757,117909,118087,118285,118488,118698,118930,119128,119351,119541',
        1491112800 => '119715,119824,119904,120035,120205,120319,120477,120619,120724,120883,121024,121136,121225,121404,121570,121733,121867,121984,122067,122175,122322,122466,122577,122737,122846,122966,123070,123206,123322,123480,123577,123736,123817,123953,124113,124210,124374,124549,124647,124810,124894,124980,125107,125192,125328,125456,125587,125674,125775,125896,126074,126185,126282,126437,126604,126761,126939,127034,127128,127244,127348,127489,127630,127793,127947,128051,128220,128323,128479,128577,128709,128837,128960,129069,129233,129337,129447,129553,129677,129763,129852,129939,130094,130197,130289,130369,130476,130561,130692,130790,130904,131004,131140,131269,131416,131538,131692,131841,132009,132112,132267,132439,132554,132652,132752,132921,133030,133125,133234,133383,133517,133623,133740,133841,133993,134109,134189,134369,134482,134584,134697,134780,134921,135046,135137,135251,135382,135488,135645,135772,135919,136002,136172,136336,136467,136629,136781,136893,137019,137178,137312,137419,137578,137744,137902,138030,138142,138297,138468,138622,138726,138891,139000,139146,139238,139398,139555,139713,139825,139933,140042,140152,140237,140414,140588,140723,140893,140995,141170,141312,141485,141620,141747,141848,141968,142104,142258,142407,142528,142636,142755,142928,143021,143154,143321,143456,143603,143696,143807,143950,144067,144220,144354,144437,144549,144638,144793,144929,145028,145156,145334,145512,145596,145709,145863,145983,146131,146229,146344,146509,146656,146818,146938,147029,147145,147251,147364,147502,147634,147744,147878,148030,148144,148320,148459,148638,148752,148871,148956,149104,149257,149342,149457,149612,149762,149876,150025,150144,150228,150387,150469,150634,150776,150887,150968,151056,151186,151288,151441,151552,151709,151791,151891,152001,152114,152266,152356,152468,152626,152740,152868,153031,153153,153311,153422,153571,153661,153792,153934,154066,154156,154238,154390,154496,154598,154724,154871,154984,155155,155243,155383,155505,155651,155781,155944,156104,156218,156340,156446,156612,156726,156814,156898,157034,157160,157275,157386,157561,157721,157894,158054,158161,158315,158406,158566,158697,158789,158931,159061,159182,159324,159464,159603,159709,159849,159952,160093,160194,160331,160417,160548,160703,160815,160945,161026,161202,161363,161491,161614,161735,161831,161967,162105,162197,162349,162480,162637,162739,162858,163031,163139,163256,163343,163467,163591,163755,163862,164022,164178,164294,164388,164510,164685,164828,164909,165036,165184,165267,165350,165437,165546,165691,165847,165998,166128,166263,166376,166475,166590,166734,166822,166991,167090,167187,167360,167507,167685,167818,167958,168133,168269,168426,168508,168617,168786,168871,169014,169095,169251,169337,169484,169613,169711,169818,169953,170054,170203,170366,170458,170586,170677,170785,170965,171110,171268,171349,171508,171593,171754,171924,172076,172209,172355,172470,172579,172697,172871,173049,173187,173312,173418,173508,173598,173776,173880,174009,174173,174263,174405,174573,174680,174780,174952,175132,175221,175344,175494,175580,175696,175793,175907,176023,176122,176292,176429,176549,176660,176757,176873,177009,177127,177215,177333,177474,177603,177759,177843,177990,178129,178304,178388,178499,178659,178757,178868,178976,179120,179299,179382,179489,179641,179758,179866,180045,180216,180345,180466,180629,180755,180857,181011,181121,181264,181440,181529,181683,181770,181893,182072,182219,182334,182510,182606,182709,182811,182988,183115,183281,183405,183497,183580,183691,183819,183955,184114,184263,184371,184471,184634,184801,184907,185046,185217,185368,185454,185624,185740,185881,185998,186106,186280,186453,186606,186718,186867,186953,187121,187278,187403,187537,187693,187839,187951,188059,188171,188273,188438,188557,188702,188810,188968,189142,189249,189391,189522,189621,189733,189885,190053,190173,190322,190465,190566,190675,190811,190989,191122,191224,191384,191552,191694,191835,191947,192104,192250,192375,192530,192647,192740,192847,193002,193112,193257,193358,193506,193673,193761,193864,194013,194105,194281,194445,194618,194783,194896,195037,195157,195283,195435,195560,195717,195875,195995,196137,196287,196398,196573,196698,196800,196967',
        1491134400 => '197084,197199,197349,197411,197524,197649,197734,197789,197863,197931,198032,198099,198201,198298,198377,198511,198622,198697,198785,198921,199049,199101,199220,199327,199450,199510,199626,199745,199803,199903,199992,200128,200268,200386,200520,200608,200726,200779,200865,200946,201015,201124,201210,201260,201338,201476,201553,201607,201709,201762,201843,201967,202029,202127,202272,202376,202506,202568,202667,202762,202907,203049,203106,203184,203289,203439,203581,203648,203738,203816,203920,204042,204103,204244,204378,204522,204633,204763,204814,204876,204966,205106,205160,205210,205262,205336,205474,205620,205683,205778,205863,205961,206028,206137,206239,206314,206382,206491,206587,206725,206810,206900,207028,207150,207212,207321,207443,207560,207647,207733,207843,207921,208051,208153,208231,208309,208441,208528,208657,208782,208901,208983,209034,209111,209239,209370,209509,209573,209631,209746,209848,209916,210001,210126,210237,210317,210465,210559,210646,210719,210826,210884,210995,211106,211253,211340,211471,211578,211672,211744,211888,212025,212116,212187,212298,212397,212456,212560,212686,212759,212818,212932,213068,213176,213256,213399,213464,213578,213680,213799,213895,214023,214147,214280,214418,214518,214571,214654,214752,214884,214999,215081,215176,215326,215405,215462,215573,215648,215703,215831,215915,216034,216120,216222,216368,216494,216617,216701,216828,216915,217039,217173,217276,217366,217457,217558,217679,217815,217940,218065,218120,218260,218316,218451,218520,218665,218765,218871,218960,219102,219228,219313,219439,219566,219640,219722,219791,219890,220036,220150,220294,220389,220518,220579,220653,220777,220827,220975,221043,221129,221232,221336,221465,221571,221636,221725,221806,221878,222024,222173,222232,222342,222403,222525,222661,222770,222833,222981,223116,223184,223330,223453,223554,223685,223746,223815,223875,224003,224153,224261,224315,224459,224592,224709,224798,224856,224973,225030,225090,225174,225238,225295,225396,225461,225568,225646,225708,225816,225921,225982,226043,226137,226204,226261,226372,226459,226553,226670,226794,226910,227003,227137,227237,227339,227443,227593,227660,227726,227823,227894,227996,228061,228163,228240,228321,228469,228561,228708,228834,228920,228982,229124,229188,229304,229434,229554,229627,229751,229824,229909,229989,230050,230171,230244,230364,230462,230518,230609,230716,230810,230914,230965,231087,231163,231246,231368,231456,231589,231687,231760,231853,231917,232062,232167,232229,232367,232486,232583,232660,232725,232818,232903,233032,233086,233136,233210,233356,233458,233549,233619,233672,233724,233785,233904,234054,234201,234345,234485,234559,234668,234792,234920,235001,235068,235206,235259,235394,235456,235559,235646,235796,235906,235986,236114,236171,236244,236339,236449,236598,236694,236785,236890,237000,237052,237121,237262,237326,237392,237490,237627,237728,237822,237900,238024,238146,238248,238326,238456,238578,238721,238838,238979,239113,239254,239389,239495,239556,239617,239682,239832,239906,240008,240089,240222,240365,240439,240589,240652,240776,240838,240962,241023,241151,241284,241405,241494,241569,241628,241714,241766,241816,241887,241978,242111,242180,242324,242424,242513,242660,242770,242837,242893,243029,243086,243220,243347,243443,243540,243590,243737,243825,243965,244087,244236,244380,244442,244528,244617,244728,244877,245026,245173,245239,245377,245512,245615,245716,245827,245969,246041,246188,246279,246393,246455,246547,246624,246697,246810,246882,246972,247105,247163,247270,247374,247431,247549,247684,247791,247859,247918,247970,248032,248152,248296,248426,248491,248630,248726,248872,248946,249078,249227,249358,249437,249565,249692,249752,249823,249934,250025,250091,250152,250236,250353,250439,250513,250567,250630,250702,250810,250919,251023,251143,251264,251332,251393,251469,251601,251721,251841,251963,252100,252214,252318,252430,252539,252674,252784,252876,252964,253113,253216,253279,253369,253464,253556,253614,253726,253795,253921,253983,254050,254152,254260,254407,254514,254630,254748,254831,254968,255052,255130,255240,255375,255471,255614,255753,255824,255910,256055,256158,256212,256321,256440,256576,256628,256752,256885,256979,257061',
        1491181200 => '257149,257253,257395,257479,257626,257722,257858,257934,258068,258132,258186,258264,258365,258505,258654,258717,258855,258914,258993,259078,259191,259287,259357,259495,259549,259688,259807,259858,259988,260087,260165,260250,260369,260456,260600,260702,260765,260870,260980,261082,261133,261280,261395,261493,261619,261696,261763,261860,261932,261987,262127,262263,262384,262522,262607,262703,262853,262985,263098,263245,263298,263414,263524,263591,263714,263826,263898,263986,264113,264179,264329,264445,264577,264688,264796,264885,264988,265056,265116,265227,265374,265445,265556,265671,265761,265829,265956,266023,266171,266279,266369,266464,266598,266655,266720,266785,266931,267002,267063,267174,267307,267406,267486,267580,267679,267793,267913,267989,268081,268164,268217,268343,268399,268509,268647,268715,268823,268909,269053,269162,269273,269412,269521,269642,269758,269880,270017,270088,270154,270296,270436,270488,270594,270722,270843,270926,271001,271072,271138,271264,271402,271522,271654,271802,271882,272014,272116,272199,272298,272360,272467,272607,272711,272813,272938,273068,273174,273226,273373,273435,273506,273656,273737,273870,273934,273995,274127,274204,274334,274441,274513,274603,274675,274820,274969,275074,275143,275237,275346,275404,275470,275604,275666,275730,275786,275917,276000,276142,276274,276368,276469,276604,276736,276839,276920,277053,277164,277288,277438,277572,277667,277759,277882,277988,278096,278157,278292,278349,278472,278528,278600,278707,278782,278913,278988,279085,279219,279337,279389,279489,279628,279713,279771,279833,279933,280057,280127,280192,280260,280375,280488,280573,280674,280815,280962,281034,281099,281193,281279,281379,281429,281538,281615,281755,281808,281935,282060,282133,282216,282281,282399,282541,282613,282758,282860,282942,282999,283067,283183,283247,283321,283426,283483,283566,283627,283750,283832,283907,284053,284167,284294,284406,284507,284580,284689,284740,284826,284973,285069,285120,285258,285321,285460,285574,285722,285867,286005,286106,286184,286312,286462,286593,286705,286811,286940,287023,287106,287200,287322,287392,287530,287592,287735,287884,287946,288041,288093,288147,288225,288298,288426,288509,288613,288714,288848,288938,289087,289213,289266,289328,289462,289549,289668,289804,289917,290052,290181,290248,290382,290486,290591,290664,290801,290869,290987,291094,291219,291352,291402,291494,291575,291708,291858,291979,292047,292108,292176,292289,292390,292502,292572,292657,292761,292868,293002,293115,293188,293287,293389,293441,293578,293643,293793,293931,293986,294103,294163,294279,294425,294570,294645,294716,294810,294937,294997,295089,295201,295263,295399,295549,295663,295774,295877,295945,296011,296154,296247,296336,296388,296487,296541,296657,296736,296848,296967,297046,297127,297251,297393,297528,297650,297769,297895,298009,298062,298197,298280,298393,298483,298580,298715,298769,298904,298961,299100,299189,299325,299421,299536,299594,299647,299722,299793,299859,299974,300034,300160,300297,300367,300502,300614,300680,300731,300861,300981,301074,301204,301305,301395,301527,301597,301713,301847,301969,302040,302178,302247,302303,302405,302522,302645,302736,302802,302913,303000,303084,303205,303301,303395,303467,303553,303683,303779,303845,303936,304052,304184,304291,304434,304517,304600,304698,304828,304935,305042,305132,305268,305349,305403,305463,305522,305613,305762,305852,305965,306069,306119,306210,306270,306341,306470,306595,306711,306788,306911,306977,307032,307096,307236,307365,307468,307618,307715,307859,307974,308025,308172,308243,308375,308504,308617,308758,308898,309001,309115,309206,309317,309375,309453,309568,309661,309796,309912,309977,310081,310201,310270,310398,310532,310593,310742,310885,310960,311046,311124,311256,311318,311404,311491,311556,311672,311821,311922,311986,312047,312148,312202,312265,312386,312443,312580,312715,312858,312956,313008,313112,313208,313319,313382,313467,313567,313651,313767,313883,313949,314004,314087,314234,314375,314445,314575,314625,314716,314774,314892,314961,315104,315170,315252,315375,315509,315569,315623,315747,315856,315954,316031,316091,316185,316253,316332,316421,316518,316606,316732,316868,316938,317003,317135,317243',
        1491199200 => '317340,317464,317534,317641,317714,317818,317908,318022,318100,318221,318328,318394,318520,318660,318789,318916,318974,319077,319164,319304,319373,319424,319480,319578,319726,319858,319962,320107,320174,320277,320417,320524,320641,320772,320850,320916,320970,321100,321164,321286,321343,321403,321539,321595,321699,321812,321884,321951,322084,322214,322278,322406,322530,322624,322755,322834,322971,323084,323175,323244,323336,323449,323552,323683,323807,323868,323941,324047,324133,324202,324287,324428,324540,324671,324803,324863,324942,324996,325070,325162,325217,325269,325396,325473,325539,325629,325736,325826,325957,326046,326098,326223,326309,326417,326547,326648,326740,326871,326994,327053,327132,327278,327389,327457,327511,327598,327748,327799,327910,328040,328180,328230,328331,328438,328497,328647,328762,328853,328996,329130,329273,329340,329458,329518,329622,329674,329800,329934,330036,330145,330236,330361,330481,330608,330665,330802,330946,331069,331159,331232,331316,331374,331520,331633,331751,331894,332037,332185,332274,332403,332543,332593,332667,332759,332873,332926,332988,333127,333236,333384,333524,333619,333702,333778,333833,333945,334054,334173,334223,334360,334475,334579,334660,334727,334800,334924,335026,335082,335192,335336,335417,335484,335624,335738,335797,335914,336036,336154,336229,336302,336400,336488,336602,336658,336711,336797,336947,337072,337169,337222,337359,337455,337583,337706,337833,337908,338052,338156,338276,338368,338440,338492,338564,338645,338771,338903,339045,339163,339269,339326,339418,339525,339644,339699,339788,339866,339979,340033,340149,340261,340370,340489,340573,340626,340717,340833,340896,340981,341052,341172,341234,341350,341494,341638,341723,341840,341963,342047,342179,342312,342382,342530,342655,342775,342877,343019,343143,343249,343377,343433,343527,343611,343713,343850,343920,343970,344098,344193,344337,344396,344464,344542,344664,344747,344873,344923,344998,345098,345185,345260,345373,345479,345621,345689,345751,345836,345961,346042,346164,346232,346313,346453,346587,346657,346734,346790,346860,347005,347091,347169,347244,347372,347497,347615,347689,347810,347909,347965,348104,348187,348335,348456,348592,348646,348730,348811,348904,348984,349129,349186,349323,349398,349490,349548,349670,349720,349798,349873,350015,350144,350224,350339,350448,350567,350711,350787,350937,351008,351077,351196,351249,351369,351511,351611,351759,351821,351922,352060,352202,352322,352422,352499,352647,352782,352888,352994,353101,353230,353286,353347,353440,353578,353690,353794,353865,353953,354091,354170,354293,354423,354565,354638,354772,354843,354933,355008,355152,355234,355313,355422,355511,355593,355725,355781,355901,355957,356043,356178,356285,356357,356415,356493,356570,356621,356753,356839,356984,357091,357204,357319,357436,357517,357594,357673,357818,357870,357922,358056,358152,358290,358382,358482,358568,358682,358737,358867,358951,359021,359147,359197,359326,359387,359494,359570,359696,359810,359878,359987,360098,360223,360362,360470,360579,360633,360697,360813,360915,361049,361129,361205,361278,361386,361510,361646,361735,361807,361932,362005,362121,362246,362313,362422,362547,362599,362737,362846,362950,363042,363163,363238,363360,363458,363587,363687,363797,363877,363960,364040,364136,364276,364384,364505,364630,364694,364836,364886,365033,365161,365243,365298,365355,365405,365496,365602,365696,365827,365951,366100,366176,366325,366412,366534,366666,366748,366897,366984,367112,367204,367260,367317,367450,367560,367630,367777,367845,367966,368101,368178,368322,368381,368431,368538,368656,368760,368841,368938,369033,369178,369235,369327,369402,369524,369656,369797,369907,369972,370034,370093,370169,370294,370356,370484,370600,370749,370838,370904,371051,371161,371239,371330,371383,371531,371622,371716,371801,371856,371933,372006,372134,372190,372278,372353,372437,372487,372554,372682,372818,372940,373044,373141,373233,373367,373426,373556,373666,373811,373910,374023,374074,374223,374347,374401,374451,374532,374624,374691,374755,374815,374877,375010,375154,375221,375292,375405,375485,375602,375666,375719,375813,375901,375998,376132,376232,376363,376498,376638,376693,376770,376894,377022',
        1491220800 => '377169,377294,377379,377512,377584,377665,377739,377816,377940,378073,378219,378285,378443,378533,378670,378788,378897,379012,379075,379172,379242,379380,379539,379643,379716,379820,379906,379968,380097,380175,380286,380403,380545,380665,380804,380942,381064,381172,381285,381384,381499,381597,381682,381836,381909,382035,382139,382272,382353,382512,382593,382697,382831,382946,383067,383173,383235,383300,383404,383490,383598,383751,383852,383912,384036,384153,384256,384333,384429,384530,384643,384705,384829,384963,385094,385246,385404,385522,385656,385723,385815,385905,386011,386151,386297,386439,386581,386716,386865,387016,387142,387301,387406,387556,387639,387779,387934,388085,388220,388307,388395,388472,388535,388668,388799,388943,389021,389091,389206,389327,389463,389547,389696,389822,389882,389942,390041,390142,390291,390415,390544,390687,390784,390849,390929,391022,391088,391243,391344,391503,391600,391717,391790,391919,392033,392159,392228,392308,392424,392504,392591,392733,392844,392961,393052,393137,393263,393406,393508,393639,393780,393908,394043,394111,394174,394287,394421,394531,394596,394745,394839,394946,395091,395248,395395,395461,395565,395685,395829,395928,396029,396091,396247,396379,396453,396545,396662,396783,396902,397057,397208,397351,397478,397565,397721,397859,397997,398109,398175,398317,398459,398546,398646,398762,398877,398944,399064,399139,399298,399427,399541,399641,399801,399910,400018,400126,400209,400296,400385,400450,400584,400725,400878,400958,401053,401185,401345,401478,401555,401630,401785,401856,402007,402128,402252,402383,402521,402660,402729,402880,402983,403104,403186,403343,403423,403515,403612,403764,403861,403923,404017,404165,404302,404439,404544,404630,404701,404840,404991,405080,405229,405335,405417,405483,405557,405670,405799,405947,406016,406121,406260,406398,406527,406638,406703,406818,406929,407058,407168,407236,407389,407540,407686,407814,407965,408105,408171,408318,408389,408498,408583,408657,408784,408858,408997,409132,409275,409432,409570,409669,409773,409869,409966,410072,410180,410330,410481,410641,410795,410922,411028,411139,411209,411283,411425,411490,411626,411732,411826,411946,412060,412190,412317,412453,412611,412693,412760,412891,412958,413082,413203,413315,413449,413548,413637,413776,413899,413983,414053,414155,414243,414323,414398,414476,414540,414601,414665,414772,414893,415050,415127,415269,415392,415496,415614,415737,415887,415975,416079,416141,416296,416356,416443,416520,416589,416738,416808,416957,417117,417209,417327,417416,417515,417584,417726,417882,418012,418164,418304,418415,418572,418678,418810,418944,419087,419221,419349,419479,419635,419783,419902,420037,420162,420319,420398,420481,420583,420658,420769,420856,420988,421136,421252,421347,421421,421545,421631,421751,421824,421931,422077,422177,422251,422349,422503,422570,422643,422769,422837,422950,423102,423247,423322,423423,423506,423585,423688,423770,423899,424035,424099,424237,424378,424525,424634,424784,424899,425009,425108,425185,425341,425479,425601,425735,425841,425906,425992,426143,426228,426369,426456,426581,426683,426749,426871,427010,427143,427246,427339,427480,427554,427681,427818,427900,428041,428167,428302,428452,428514,428664,428738,428842,428946,429103,429214,429367,429496,429625,429715,429804,429896,429997,430076,430224,430338,430407,430467,430563,430718,430840,430979,431133,431270,431430,431556,431653,431777,431895,432007,432138,432215,432336,432417,432481,432546,432704,432836,432963,433033,433116,433181,433341,433406,433553,433677,433829,433895,434048,434164,434276,434348,434485,434618,434740,434883,435019,435097,435181,435242,435384,435459,435522,435595,435661,435783,435847,435945,436011,436147,436276,436407,436554,436667,436754,436885,437044,437128,437219,437357,437478,437565,437693,437842,437939,438001,438066,438132,438232,438312,438391,438502,438614,438706,438818,438893,439049,439131,439264,439344,439484,439548,439684,439790,439908,439976,440123,440283,440433,440588,440745,440860,440970,441071,441212,441361,441493,441574,441639,441743,441885,441952,442048,442167,442244,442364,442506,442596,442687,442776,442857,442964,443112,443202,443306,443445,443565,443712,443821,443908,443995',
        1491267600 => '444158,444314,444478,444616,444753,444857,444952,445112,445265,445338,445470,445590,445759,445925,446009,446085,446190,446320,446425,446540,446630,446733,446807,446885,447017,447119,447214,447347,447479,447628,447778,447933,448026,448173,448334,448427,448556,448717,448833,448926,449045,449125,449195,449294,449396,449479,449581,449666,449761,449847,450006,450136,450267,450382,450488,450611,450681,450834,450937,451103,451198,451270,451405,451476,451612,451688,451792,451873,452030,452171,452321,452457,452538,452668,452785,452918,453039,453185,453270,453352,453487,453565,453689,453786,453869,453964,454072,454215,454348,454422,454505,454627,454765,454909,455006,455146,455248,455333,455447,455539,455649,455813,455914,456082,456248,456350,456448,456532,456690,456843,456934,457054,457200,457330,457429,457509,457590,457730,457833,457936,458101,458246,458405,458495,458621,458749,458832,458986,459120,459245,459353,459443,459520,459631,459708,459875,459948,460098,460264,460389,460539,460612,460731,460804,460937,461011,461129,461232,461382,461463,461594,461732,461852,461958,462063,462191,462316,462437,462530,462651,462785,462954,463087,463179,463283,463427,463504,463635,463800,463967,464108,464227,464306,464385,464521,464655,464810,464959,465098,465260,465396,465548,465677,465756,465922,466060,466194,466280,466380,466475,466626,466747,466884,467016,467149,467265,467424,467500,467645,467716,467821,467934,468006,468088,468208,468367,468503,468668,468825,468909,469005,469129,469217,469342,469494,469647,469721,469829,469927,470038,470151,470299,470402,470544,470702,470775,470940,471026,471168,471305,471403,471523,471671,471806,471910,471989,472127,472288,472418,472489,472608,472690,472854,473017,473119,473196,473345,473436,473560,473688,473841,473961,474037,474171,474241,474374,474459,474543,474627,474749,474838,474938,475067,475139,475224,475310,475405,475537,475637,475803,475913,476074,476157,476324,476475,476642,476718,476882,477036,477169,477327,477436,477564,477710,477801,477967,478070,478218,478370,478518,478686,478829,478935,479032,479110,479280,479421,479502,479657,479790,479881,479956,480062,480175,480248,480358,480461,480615,480707,480818,480972,481137,481280,481419,481531,481626,481792,481955,482070,482188,482330,482498,482597,482681,482776,482916,482990,483131,483287,483440,483604,483748,483864,483966,484038,484160,484318,484401,484534,484606,484734,484899,484987,485151,485295,485420,485529,485608,485682,485819,485901,486005,486094,486217,486311,486385,486528,486642,486761,486862,486961,487049,487210,487345,487441,487592,487683,487848,487985,488073,488224,488310,488442,488555,488666,488819,488973,489095,489201,489369,489523,489661,489774,489876,490012,490113,490280,490415,490557,490645,490734,490902,490997,491143,491226,491319,491428,491502,491657,491738,491898,492000,492100,492206,492285,492417,492557,492627,492733,492826,492977,493111,493212,493338,493468,493576,493742,493876,493998,494121,494251,494393,494519,494616,494742,494907,494999,495081,495247,495407,495486,495623,495764,495902,495990,496062,496143,496252,496353,496497,496579,496709,496833,496972,497047,497210,497351,497447,497611,497780,497950,498066,498194,498309,498390,498467,498623,498742,498816,498922,499000,499143,499234,499361,499472,499593,499717,499858,499977,500051,500183,500304,500426,500560,500713,500797,500903,500983,501064,501207,501320,501455,501581,501659,501753,501838,501946,502018,502152,502276,502439,502576,502673,502830,502962,503087,503157,503288,503421,503492,503631,503796,503921,504042,504151,504249,504337,504407,504568,504680,504779,504936,505089,505182,505312,505451,505595,505716,505804,505928,506014,506119,506261,506336,506460,506565,506714,506836,506945,507108,507208,507355,507432,507503,507651,507785,507912,508056,508127,508216,508369,508505,508605,508738,508812,508960,509076,509163,509291,509420,509503,509622,509775,509917,510038,510199,510320,510458,510558,510704,510784,510855,510948,511095,511223,511380,511539,511688,511786,511942,512014,512181,512333,512498,512581,512737,512903,513053,513201,513357,513444,513514,513588,513701,513784,513862,513991,514104,514201,514274,514351,514476,514565,514641,514771,514915,515030,515119,515197,515289',
        1491285600 => '515394,515537,515640,515758,515899,516045,516121,516255,516387,516541,516685,516811,516980,517078,517205,517363,517497,517573,517716,517886,518017,518092,518188,518299,518419,518550,518636,518761,518930,519085,519242,519370,519498,519631,519743,519884,519997,520109,520211,520318,520481,520587,520743,520882,520985,521118,521275,521414,521550,521682,521762,521882,521976,522097,522253,522342,522422,522570,522710,522798,522951,523072,523154,523304,523427,523543,523648,523817,523975,524098,524213,524355,524460,524537,524661,524789,524930,525078,525235,525402,525484,525576,525715,525823,525978,526059,526223,526314,526385,526467,526619,526701,526848,526996,527127,527245,527329,527479,527599,527717,527871,527952,528068,528183,528274,528372,528527,528651,528758,528840,528985,529081,529205,529317,529438,529527,529630,529724,529852,529985,530060,530188,530347,530500,530663,530785,530873,531024,531117,531285,531373,531515,531661,531735,531893,532006,532144,532271,532344,532425,532522,532611,532688,532825,532990,533108,533254,533333,533413,533563,533643,533780,533853,533986,534104,534242,534349,534501,534596,534756,534846,534993,535144,535252,535334,535488,535598,535720,535841,535961,536069,536210,536370,536450,536531,536687,536781,536920,537089,537163,537302,537471,537620,537777,537852,538006,538168,538269,538377,538470,538584,538724,538802,538896,538991,539127,539205,539292,539414,539514,539677,539828,539994,540111,540257,540403,540525,540682,540840,540987,541143,541276,541418,541539,541650,541800,541879,541970,542076,542246,542348,542468,542556,542664,542778,542890,542999,543124,543248,543393,543520,543677,543810,543912,543985,544103,544181,544344,544427,544522,544595,544674,544794,544891,545039,545178,545335,545430,545555,545677,545747,545834,545998,546122,546271,546367,546438,546605,546767,546855,547008,547130,547231,547324,547461,547544,547629,547771,547875,548028,548101,548238,548376,548520,548654,548774,548935,549105,549214,549293,549444,549544,549636,549724,549845,549942,550105,550180,550325,550408,550574,550653,550801,550886,551033,551178,551316,551445,551562,551703,551868,551959,552110,552278,552404,552474,552644,552726,552797,552920,553013,553146,553293,553395,553538,553611,553780,553850,553939,554033,554170,554247,554319,554488,554654,554744,554911,555063,555229,555364,555480,555552,555688,555794,555894,555967,556114,556276,556364,556458,556568,556642,556780,556946,557060,557148,557252,557341,557509,557621,557776,557875,558018,558122,558241,558344,558414,558492,558565,558676,558788,558923,559044,559205,559291,559373,559447,559592,559693,559834,559983,560074,560211,560290,560390,560479,560600,560720,560881,561006,561099,561259,561367,561450,561587,561714,561816,561958,562073,562238,562315,562459,562620,562745,562902,563054,563204,563292,563364,563492,563657,563767,563886,564034,564187,564270,564344,564446,564532,564627,564713,564856,564940,565093,565244,565391,565551,565693,565781,565875,566007,566122,566282,566361,566462,566616,566754,566922,567001,567146,567256,567414,567516,567648,567734,567900,568016,568116,568261,568393,568550,568637,568716,568826,568913,569045,569214,569322,569451,569586,569674,569746,569904,570004,570171,570270,570416,570582,570717,570821,570983,571065,571140,571236,571390,571558,571664,571736,571822,571964,572064,572157,572230,572338,572420,572491,572576,572740,572840,572975,573086,573227,573358,573456,573603,573732,573811,573943,574034,574138,574237,574386,574508,574646,574781,574886,574993,575067,575147,575280,575447,575600,575679,575763,575928,576081,576242,576411,576510,576640,576778,576859,576952,577108,577195,577334,577476,577617,577717,577860,577951,578112,578246,578368,578470,578589,578751,578847,578980,579124,579199,579363,579498,579591,579675,579768,579869,580002,580106,580228,580368,580451,580527,580608,580741,580907,581015,581088,581237,581351,581498,581605,581685,581793,581961,582095,582212,582337,582435,582548,582662,582740,582860,582978,583081,583164,583239,583327,583397,583482,583558,583658,583755,583865,583947,584025,584136,584254,584330,584479,584595,584713,584863,584962,585076,585232,585373,585523,585624,585730,585824,585972,586060,586172,586335,586420,586502,586649,586764,586834',
        1491307200 => '586958,587115,587223,587340,587429,587545,587666,587759,587840,587922,588025,588126,588200,588313,588408,588569,588722,588877,589035,589178,589348,589504,589658,589773,589933,590087,590242,590385,590487,590597,590737,590846,590927,591001,591101,591251,591329,591452,591543,591634,591710,591836,591976,592108,592209,592378,592493,592638,592725,592838,592952,593065,593158,593261,593403,593478,593618,593780,593888,593999,594132,594302,594431,594594,594731,594824,594919,595004,595136,595244,595323,595470,595606,595687,595838,595951,596046,596117,596203,596288,596423,596528,596673,596810,596968,597080,597170,597255,597402,597532,597638,597759,597890,597983,598110,598244,598412,598554,598648,598807,598921,599065,599182,599288,599454,599530,599650,599743,599865,599937,600077,600164,600290,600407,600528,600631,600786,600942,601105,601212,601359,601521,601669,601739,601905,602036,602154,602268,602403,602546,602642,602771,602924,603065,603215,603308,603442,603544,603694,603790,603906,604033,604148,604281,604427,604580,604668,604831,604923,605047,605141,605251,605405,605571,605649,605787,605955,606115,606189,606272,606372,606527,606692,606860,607002,607115,607241,607315,607439,607602,607749,607819,607916,608060,608135,608266,608370,608444,608578,608718,608820,608940,609034,609172,609306,609448,609611,609743,609847,609945,610061,610196,610327,610455,610584,610663,610828,610898,610989,611078,611164,611252,611346,611455,611530,611613,611749,611851,611986,612076,612204,612303,612374,612505,612668,612743,612830,612935,613100,613207,613361,613479,613635,613729,613860,613964,614048,614145,614310,614398,614528,614634,614746,614888,614964,615114,615220,615298,615378,615462,615548,615668,615768,615840,615954,616054,616182,616325,616483,616621,616694,616844,616933,617073,617216,617352,617443,617610,617705,617823,617980,618145,618269,618365,618521,618597,618694,618803,618878,618994,619079,619190,619281,619406,619508,619590,619703,619799,619947,620068,620220,620307,620444,620575,620740,620824,620974,621082,621157,621227,621298,621393,621510,621603,621744,621838,621926,622093,622183,622336,622486,622632,622795,622878,623048,623144,623223,623374,623477,623587,623719,623809,623900,623976,624086,624156,624261,624419,624519,624637,624760,624874,624990,625094,625264,625377,625476,625557,625657,625762,625921,626068,626232,626361,626477,626623,626747,626915,627023,627112,627253,627412,627524,627676,627842,627915,628057,628191,628267,628363,628510,628612,628702,628801,628911,629076,629228,629316,629439,629548,629699,629862,629989,630147,630290,630411,630527,630687,630781,630899,631024,631161,631323,631478,631596,631678,631843,632002,632145,632267,632353,632440,632543,632689,632853,633014,633097,633225,633372,633468,633551,633649,633748,633827,633930,634081,634238,634360,634478,634554,634698,634836,634937,635088,635166,635323,635484,635560,635667,635792,635935,636082,636173,636266,636388,636550,636712,636867,637014,637115,637185,637275,637382,637537,637663,637756,637923,638083,638190,638355,638519,638598,638760,638927,639007,639164,639331,639429,639595,639715,639826,639910,640040,640144,640251,640413,640542,640615,640765,640857,641001,641149,641292,641402,641486,641632,641705,641869,642028,642127,642287,642446,642548,642701,642790,642948,643023,643183,643305,643473,643560,643699,643794,643945,644039,644173,644339,644496,644570,644697,644787,644912,645068,645155,645262,645397,645512,645583,645722,645849,645949,646035,646133,646203,646331,646486,646653,646807,646963,647042,647115,647278,647372,647475,647579,647738,647858,647960,648034,648104,648254,648418,648528,648667,648772,648894,649040,649171,649334,649427,649580,649746,649866,649961,650118,650194,650265,650342,650460,650591,650726,650894,650992,651081,651202,651298,651409,651557,651664,651747,651891,651991,652075,652201,652370,652477,652639,652763,652894,653060,653142,653262,653359,653491,653609,653767,653915,654011,654102,654251,654419,654509,654593,654706,654850,654940,655071,655232,655338,655474,655628,655742,655851,655935,656103,656259,656368,656453,656612,656774,656854,656993,657107,657253,657410,657574,657701,657775,657877,657988,658098,658238,658371,658495,658650,658783,658855,659023,659136,659279',
        1491393600 => '588,1177,1607,1985,2412,2981,3393,3745,4385,4803,5425,6049,6467,6899,7327,7814,8264,8770,9373,10002,10530,10920,11418,11942,12434,12934,13522,14028,14626,15074,15585,15955,16584,17109,17474,18109,18647,19087,19640,20217,20796,21428,22017,22603,22980,23339,23772,24221,24695,25054,25700,26067,26501,27077,27716,28365,28764,29172,29643,30227,30688,31286,31675,32204,32593,32972,33350,33717,34344,34715,35204,35751,36356,36927,37411,37929,38507,39136,39562,40021,40452,40873,41421,41826,42387,42964,43600,43963,44381,44769,45261,45725,46261,46861,47457,47960,48337,48875,49320,49800,50389,50884,51328,51693,52300,52915,53554,54066,54573,55139,55508,56095,56705,57102,57542,58068,58656,59018,59584,60216,60848,61251,61725,62094,62666,63115,63613,64001,64488,64990,65593,66119,66537,67095,67493,68010,68612,69118,69470,70055,70480,70902,71282,71670,72212,72793,73422,73804,74437,74801,75240,75723,76302,76865,77222,77823,78226,78659,79049,79565,80009,80618,80982,81601,82126,82625,82994,83549,84166,84516,85027,85383,85919,86274,86644,87020,87374,87868,88375,88946,89373,89857,90355,90825,91254,91716,92126,92535,93133,93544,94187,94654,95199,95820,96464,96992,97616,98055,98691,99109,99723,100359,100962,101605,102143,102761,103138,103730,104354,104844,105327,105921,106511,107102,107735,108378,109009,109514,110110,110599,111195,111831,112283,112797,113173,113691,114127,114564,115020,115543,115940,116504,116948,117321,117728,118139,118757,119343,119810,120405,120840,121306,121881,122440,122931,123481,124092,124461,124991,125560,125997,126376,126877,127415,127826,128289,128644,129186,129818,130255,130627,131260,131859,132220,132857,133312,133901,134454,134984,135344,135733,136187,136651,137069,137478,138069,138574,139113,139545,140000,140637,141190,141755,142346,142946,143424,143946,144551,144902,145411,145907,146372,146909,147486,147904,148474,148967,149571,149998,150373,150763,151132,151585,152153,152755,153210,153605,154110,154628,155069,155454,156032,156644,157127,157650,158121,158605,158968,159517,160052,160676,161135,161659,162145,162519,163142,163733,164284,164639,165199,165699,166228,166845,167375,167849,168222,168664,169161,169706,170172,170541,170913,171504,172041,172625,173040,173494,173848,174384,174763,175308,175790,176419,177051,177434,177977,178625,179063,179685,180238,180788,181355,181736,182320,182888,183288,183775,184230,184717,185338,185707,186242,186763,187114,187749,188340,188908,189331,189945,190321,190793,191330,191877,192444,192878,193427,193832,194309,194876,195260,195805,196305,196689,197207,197842,198255,198805,199190,199767,200242,200822,201398,201996,202515,203162,203712,204242,204676,205171,205754,206219,206586,207217,207590,207961,208544,209178,209689,210307,210901,211454,211869,212322,212877,213286,213930,214285,214661,215166,215708,216113,216566,217005,217379,217823,218292,218694,219139,219645,220188,220634,221033,221437,222081,222730,223155,223696,224281,224838,225362,225804,226294,226654,227269,227835,228185,228636,229155,229804,230276,230923,231569,231973,232449,232922,233466,234112,234526,234983,235535,235887,236469,236996,237474,237949,238439,239043,239427,239968,240555,241089,241701,242343,242770,243226,243617,244130,244705,245280,245858,246208,246582,247130,247719,248097,248519,248870,249407,249808,250255,250847,251424,252028,252531,253044,253416,253882,254366,254755,255353,255955,256461,256817,257271,257642,258205,258656,259109,259644,259994,260451,260878,261483,261834,262351,262801,263289,263696,264329,264780,265317,265963,266395,266806,267325,267864,268329,268773,269416,269833,270241,270644,271259,271689,272200,272811,273267,273765,274231,274586,275167,275555,276043,276681,277147,277757,278338,278765,279359,279990,280408,280897,281294,281662,282028,282408,282880,283385,283754,284276,284644,285151,285691,286276,286714,287189,287594,288172,288603,289091,289500,289882,290254,290793,291325,291881,292408,293055,293411,293814,294443,295071,295426,295910,296300,296730,297249,297619,298196,298745',
        1491480000 => '594,1184,1659,2306,2901,3439,3838,4485,4890,5246,5753,6176,6609,6966,7579,8178,8594,9222,9754,10112,10635,11259,11654,12116,12480,12950,13494,14139,14652,15163,15682,16117,16551,16990,17569,18137,18526,18909,19295,19936,20336,20881,21359,21733,22323,22707,23286,23921,24503,24916,25322,25749,26388,26797,27212,27848,28341,28692,29132,29648,30252,30721,31366,31848,32431,33054,33531,34000,34610,35156,35773,36355,36794,37175,37551,37995,38465,38946,39379,39827,40312,40914,41414,41833,42323,42682,43171,43607,44101,44611,44999,45612,46101,46711,47207,47810,48232,48798,49279,49925,50352,50805,51313,51888,52452,52993,53446,53829,54316,54672,55313,55754,56321,56807,57440,57972,58426,58923,59448,60068,60569,61176,61710,62181,62734,63133,63522,64170,64778,65255,65905,66554,67032,67460,67964,68494,69003,69398,70033,70584,71089,71689,72046,72465,73100,73496,74057,74499,74909,75531,76176,76703,77209,77768,78153,78680,79056,79446,79926,80404,80983,81540,82046,82629,83168,83656,84298,84759,85199,85836,86419,87039,87569,88134,88509,88910,89530,90064,90471,90975,91354,91776,92241,92637,93084,93550,94166,94575,95019,95533,96125,96498,96927,97399,97833,98269,98748,99222,99834,100375,101012,101651,102146,102601,103177,103732,104317,104680,105083,105536,106009,106595,107055,107692,108273,108721,109357,109846,110389,110880,111258,111619,111988,112632,112998,113492,114099,114659,115029,115573,116113,116702,117186,117822,118437,118872,119389,119903,120526,121141,121507,121965,122515,122978,123469,123867,124465,124869,125281,125656,126083,126526,126962,127339,127920,128408,128913,129526,130024,130656,131085,131578,132098,132579,133086,133693,134095,134641,135139,135744,136305,136865,137435,137989,138362,138759,139216,139587,140118,140661,141281,141850,142361,142959,143437,144068,144715,145246,145748,146169,146634,147183,147569,148165,148745,149386,149806,150338,150964,151479,152110,152609,153256,153853,154288,154729,155283,155886,156237,156868,157428,158034,158481,158980,159514,160115,160520,161076,161659,162165,162691,163058,163501,163987,164607,165016,165544,165987,166595,167193,167824,168276,168707,169224,169842,170448,170836,171196,171763,172248,172617,173101,173703,174112,174577,175196,175682,176245,176795,177288,177650,178281,178633,179249,179756,180117,180686,181073,181593,182158,182662,183029,183497,183869,184327,184957,185479,185829,186302,186798,187400,187915,188319,188909,189289,189834,190401,190800,191197,191842,192218,192685,193151,193781,194348,194733,195228,195865,196389,196816,197222,197681,198320,198753,199212,199790,200391,201021,201396,202012,202378,202814,203376,203786,204169,204539,204895,205249,205894,206430,207079,207715,208332,208839,209301,209883,210309,210778,211202,211685,212068,212441,212974,213381,213929,214311,214701,215234,215671,216313,216820,217242,217652,218245,218838,219291,219749,220282,220928,221532,221918,222460,223074,223520,224107,224608,225111,225753,226189,226677,227243,227720,228369,228834,229299,229715,230289,230881,231512,232101,232746,233368,233744,234364,235008,235630,236158,236605,237169,237727,238263,238678,239029,239413,239829,240401,241036,241397,241786,242309,242858,243326,243863,244387,244944,245521,246005,246458,246989,247613,248179,248699,249174,249691,250322,250892,251437,252035,252574,253099,253526,254171,254773,255246,255793,256296,256707,257151,257725,258126,258590,259128,259766,260399,260791,261287,261891,262430,262872,263248,263808,264213,264648,265041,265438,266069,266554,266945,267368,268018,268436,268882,269360,269808,270362,270973,271431,271854,272334,272944,273336,273758,274373,274870,275476,276019,276412,277003,277586,278232,278675,279262,279695,280231,280734,281377,281982,282488,282844,283261,283680,284136,284717,285068,285614,286224,286598,287246,287776,288324,288845,289276,289626,290110,290603,291141,291551,292104,292666,293238,293721,294295,294850,295456,295884,296440,297056,297453,297810,298396,298875,299310,299753,300205,300712,301095,301512,302037,302477,303044',
    ];

    protected $wechat;

    public function __construct() {
        $this->wechat = app('wechat');
    }

    /**
     * 获取下一次的时间
     *
     * @return int|mixed
     */
    private function getNextTime() {
        $next = 0;
        foreach (self::times as $time=>$total) {
            if (time() < ($time + self::activity_time)) {
                $next = $time;
                break;
            }
        }

        return $next;
    }

    /**
     * 获取服务器当前时间
     *
     * @return [type] [description]
     */
    public function getServerTime() {
        $data = [
            'ts' => time(),
            'next' => $this->getNextTime(),
        ];
        $this->echoJson(0, '', $data);
    }

    /**
     * 获取状态
     *
     * @return 0未开始 1进行中 2已结束
     */
    public function getStatus() {
        $status = 0;

        // 获取下一次活动开始的时间，判断是否开始
        $start_ts = $this->getNextTime();
        if (time() >= $start_ts) {
            $status = 1;
        }

        $this->echoJson(0, '', ['status' => $status]);
    }

    /**
     * 获取总量
     *
     */
    public function getTotal() {

        $nextTime = $this->getNextTime();
        $index = time() - $nextTime;

        $numbers = explode(',', self::times[$nextTime]);

        $total = array_key_exists($index, $numbers) ? $numbers[$index] : $numbers[max(array_keys($numbers))];

        $this->echoJson(0, '', ['total' => $total]);
    }

    /**
     * 概率
     *
     * @return int|string
     */
    private function getRand()
    {
        $s = 0;
        foreach (self::yb_type as $k => $v) {
            $s += $v['rate'];
        }

        //概率数组循环
        foreach (self::yb_type as $k => $v) {
            //抽取随机数
            if (mt_rand(1, $s) <= $v['rate']) {
                //得出结果
                $r = $k;
                break;
            } else {
                $s -= $v['rate'];
            }
        }

        return $r;
    }

    /**
     * 抢夺金元宝
     *
     * @return [type] [description]
     */
    public function seizeYb()
    {
        // 当前登录用户
        $user = auth()->user();

        // 判断是否开始
        $start_ts = $this->getNextTime();
        if (time() < $start_ts) {
            return $this->echoJson(1, '活动将在' . date('Y-m-d H:i', $start_ts) . '开始');
        }

        $type = '';
        $id = 0;

        // 获取Redis实例
        $redis = $this->getRedis();
        // 限定抢宝频率为1000毫秒
        $key = "jbp:limit:frequency:" . $user->id;
        if ($redis->set($key, 'Y', Array('nx', 'px' => 1000))) {
            $rand = 6;
            if (in_array($user->id, [19646, 20331])) {
                $rand = 1;
            }

            //判断是否落入概率区间
            if (mt_rand(1, 10) <= $rand) {
                $type = $this->getRand();

                $id = DB::table('game_jbp_user_yb_pending')->insertGetId([
                    'user_id' => $user->id,
                    'type' => $type,
                    'created_at' => Carbon::now(),
                    'updated_at' => Carbon::now(),
                ]);
            }
        }

        dispatch((new GameJbpSeize($user->id, $id, [
            'begin_time' => $this->getNextTime(),
            'activity_time' => self::activity_time,
            'yb_total_num' => self::yb_total_num,
        ]))->delay(Carbon::now()->addSeconds(self::activity_time)));

        return $this->echoJson(0, '', ['type' => $type]);
    }

    /**
     * 使用金元宝
     *
     * @return [type] [description]
     */
    public function comsumeYb()
    {
        // 当前登录用户
        $uid = $this->getLoginUser();

        // 获取Redis实例
        $redis = $this->getRedis();

        // 限定操作频次
        $key = "jbp:comsumeYb:$uid";
        if (!$redis->set($key, 'Y', Array('nx', 'px' => 1000))) {
            return $this->echoJson(1, '您的操作过于频繁，请稍后再试');
        }

        // 用户能够投入聚宝盆的金元宝数量，限定次数与时间间隔
        $yb_num = [];
        foreach (self::yb_type as $k => $v) {
            if ($count = DB::table('game_jbp_user_yb')
                ->where('uid', $uid)
                ->where('type', $k)
                ->where('used_times', '<', $v['limit'])
                ->where('last_use_time', '<', Carbon::now()->startOfDay()->timestamp)
                ->count()
            ) {
                $yb_num[$k] = $count;
            }
        }

        if (count($yb_num) <= 0) {
            return $this->echoJson(1, '您暂无可使用元宝');
        }

        // 每个元宝每次使用获取对应的人民币
        $earn_xyb = 0;
        foreach ($yb_num as $k => $v) {
            $earn_xyb = bcadd($earn_xyb, floatval(bcmul(intval($v), self::yb_type[$k]['xyb'], 2)), 2);
        }

        // 事务
        DB::transaction(function () use ($redis, $uid, $earn_xyb) {
            // 更新用户小妖币
            $this->updateUserXYB($uid, $earn_xyb);
            // 更新用户元宝使用次数
            foreach (self::yb_type as $k => $v) {
                DB::table('game_jbp_user_yb')
                    ->where('uid', $uid)
                    ->where('type', $k)
                    ->where('used_times', '<', $v['limit'])
                    ->where('last_use_time', '<', Carbon::now()->startOfDay()->timestamp)
                    ->increment('used_times', 1, ['last_use_time' => time()]);
            }
            // 统计当日盈亏
            $this->statDayProfitAndLoss(-$earn_xyb);
        });


        return $this->echoJson(0, '', ['earn_xyb' => $earn_xyb * 100]);
    }

    /**
     * 金元宝状态
     *
     * @return [type] [description]
     */
    public function getYbStatus() {
        $uid = $this->getLoginUser();
        DB::setFetchMode(\PDO::FETCH_ASSOC);
        $new_yb_status = [];
        $yb_status = DB::table('game_jbp_user_yb_pending')->where('user_id', $uid)->where('status', 0)->select(['type','status'])->orderBy('created_at', 'desc')->get();
        if (!empty($yb_status)) {
            foreach($yb_status as $yb) {
                $yb['used_times'] = 0;
                if($yb['left_time'] = self::yb_type[$yb['type']]['limit'] - intval($yb['used_times'])){
                    $new_yb_status[] = $yb;
                }
            }
            unset($yb);
        }
        $yb_status = DB::table('game_jbp_user_yb')->where('uid', $uid)->select(['type', 'used_times'])->orderBy('created_time', 'desc')->get();
        if (!empty($yb_status)) {
            foreach($yb_status as $yb) {
                if($yb['left_time'] = self::yb_type[$yb['type']]['limit'] - intval($yb['used_times'])){
                    $new_yb_status[] = $yb;
                }
            }
            unset($yb);
        }

        $data = [
            'yb_status' => $new_yb_status
        ];
        $this->echoJson(0, '', $data);
    }

    /**
     * 获取用户个人信息
     *
     * @return [type] [description]
     */
    public function getUserInfo() {
        $uid = $this->getLoginUser();
        DB::setFetchMode(\PDO::FETCH_ASSOC);
        $user = DB::table('user')->select('id', 'nickname', 'avatar')->where('id', $uid)->first();
        $user['XYB'] = UserCoinLog::totalXyb($user['id']) * 100;
        $user['JB'] = UserCoinLog::totalJb($user['id']);
        $yb_num = DB::table('game_jbp_user_yb')->where('uid', $uid)->count();
        $user['YB'] = max($yb_num, 0);

        $user['YB'] = 0;
        foreach (self::yb_type as $k => $v) {
            $user['YB'] += DB::table('game_jbp_user_yb')
                ->where('uid', $uid)
                ->where('type', $k)
                ->where('used_times', '<', $v['limit'])
                ->count();
        }

        $this->echoJson(0, '', $user);
    }


    //////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * 统计当日盈利情况（记录保留7天）
     *
     * @param  [type] $gold [description]
     * @return [type]       [description]
     */
    private function statDayProfitAndLoss($gold) {
        $redis = $this->getRedis();
        $day_stat_key = sprintf("jbp:stat:profit:%s", date('Ymd', time()));
        $redis->incrByFloat($day_stat_key, $gold);
        $redis->setTimeout($day_stat_key, 7*24*60*60);
    }

    /**
     * 统计当日发放数量（记录保留7天）
     *
     * @param  [type] $gold [description]
     * @return [type]       [description]
     */
    private function statDayOfferYbNum() {
        $redis = $this->getRedis();
        $day_stat_key = sprintf("jbp:stat:yb:issue:num:%s", date('Ymd', time()));
        $redis->incrBy($day_stat_key, 1);
        $redis->setTimeout($day_stat_key, 7*24*60*60);
    }

    /**
     * 批量更新多用户小妖币
     *
     * @param  [type] $uid  [description]
     * @param  [type] $gold [description]
     * @return [type]       [description]
     */
    private function batchUpdateUserXYB($uid_list , $gold) {
        foreach($uid_list as $uid) {
            $this->updateUserXYB($uid, $gold);
        }
    }

    /**
     * 更新用户小妖币
     *
     * @param  [type] $uid  [description]
     * @param  [type] $gold [description]
     * @return [type]       [description]
     */
    private function updateUserXYB($uid, $gold) {
        $key = [
            'business_id' => self::business_id,
            'uid' => $uid,
            'xyb' => $gold,
            'ts' => time(),
        ];
        $key = json_encode($key);
        $tips = $gold > 0 ? '聚宝盆赢得小妖币' : '聚宝盆消耗小妖币';
        UserCoinLog::log(self::business_id, $uid, UserCoinLog::TYPE_XYB, $gold, $tips, $key);
    }

    /**
     * 更新用户小妖币
     *
     * @param  [type] $uid  [description]
     * @param  [type] $gold [description]
     * @return [type]       [description]
     */
    private function updateUserJB($uid, $gold) {
        $key = [
            'business_id' => self::business_id,
            'uid' => $uid,
            'jb' => $gold,
            'ts' => microtime(true),
        ];
        $key = json_encode($key);
        UserCoinLog::log(self::business_id, $uid, UserCoinLog::TYPE_JB, $gold, '聚宝盆消耗金币', $key);
    }

    /**
     * 告警（短信）
     *
     * @param  string $phone   [电话]
     * @param  string $message [信息]
     * @return [type]          [description]
     */
    private function alarmSms($phone = '15011931913', $message = '告警邮件') {
        try {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "http://sms-api.luosimao.com/v1/send.json");
            curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 8);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($ch, CURLOPT_HEADER, FALSE);
            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
            curl_setopt($ch, CURLOPT_USERPWD, 'api:key-5145112f10b704bbd5592f80402c77b5');
            curl_setopt($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, array('mobile' => $phone, 'message' => $message));
            $res = curl_exec($ch);
            curl_close( $ch );
        } catch (\Exception $e) {
            Log::warn("发送告警邮件失败！" . $e->getMessage());
        }
    }

    /**
     * 验证登录
     *
     * @return [type] [description]
     */
    private function getLoginUser() {
        // 检查用户登录态
        $user = auth()->user();
        $uid = $user->id;
        return $uid;
    }

    /**
     * 获取Redis实例
     *
     * @return [type] [description]
     */
    private function getRedis() {
        static $redis = null;
        if (empty($redis)) {
            $redis = new \Redis();
            $redis->connect(env('REDIS_HOST'), env('REDIS_PORT'));
            $redis->auth(env('REDIS_PASSWORD'));
        }
        return $redis;
    }

    /**
     * 响应JSON/JSONP格式数据
     *
     * @param  integer $code [返回代码：0 成功 1 失败]
     * @param  string  $msg  [错误信息]
     * @param  array   $data [返回数据]
     * @return [type]        [description]
     */
    private function echoJson($code = 0, $msg = '', $data = []) {
        header('Content-type: application/json');
        $result = [
            'code'  => $code,
            'msg'   => $msg,
            'data'  => $data,
        ];
        $json = json_encode($result);

        // JSONP
        if (!empty($_GET['callback'])) {
            $json = $_GET['callback'] . "(" . $json . ")";
        }
        echo $json;
        exit(0);
    }

}
